package com.southminority.ethnic.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 课程类型枚举
 * @author ASHTR
 */
@Getter
@AllArgsConstructor
public enum CourseTypeEnum {
    
    ETHNIC_LANGUAGE_LEARNING(1, "民族语学习"),
    ORAL_LITERATURE(2, "口头文学"),
    ETHNIC_LITERATURE_INTERPRETATION(3, "民族文献解读"),
    NATIONAL_COMMON_LANGUAGE(4, "少数民族学习国家通用语");
    
    private final Integer code;
    private final String description;
    
    /**
     * 根据code获取枚举
     * @param code 类型代码
     * @return 对应的枚举值
     */
    public static CourseTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (CourseTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }
    
    /**
     * 根据code获取描述
     * @param code 类型代码
     * @return 类型描述
     */
    public static String getDescriptionByCode(Integer code) {
        CourseTypeEnum type = getByCode(code);
        return type != null ? type.getDescription() : "未知类型";
    }
} 